package com.ja.openchat.ui.found;

import androidx.recyclerview.widget.DiffUtil;

import com.zy.openchat.core.model.circle.BlogUnreadInfo;

import java.util.List;

public class BlogMessageAvatarDiffCallBack extends DiffUtil.Callback{

    private List<BlogUnreadInfo> mOldDatas, mNewDatas;

    public BlogMessageAvatarDiffCallBack(List<BlogUnreadInfo> oldDatas, List<BlogUnreadInfo> newDatas) {
        this.mOldDatas = oldDatas;
        this.mNewDatas = newDatas;
    }


    @Override
    public int getOldListSize() {
        return mOldDatas != null ? mOldDatas.size() : 0;
    }

    // 新数据集 size
    @Override
    public int getNewListSize() {
        return mNewDatas != null ? mNewDatas.size() : 0;
    }


    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        BlogUnreadInfo oldEn = mOldDatas.get(oldItemPosition);
        BlogUnreadInfo newEn = mNewDatas.get(newItemPosition);
        return oldEn.isMessageEqual(newEn);
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        BlogUnreadInfo oldEn = mOldDatas.get(oldItemPosition);
        BlogUnreadInfo newEn = mNewDatas.get(newItemPosition);
        return oldEn.isAvaterDownloadEqual(newEn)||oldEn.isReplyUserEqual(newEn);
    }
}
